﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace Cabal.Kernel.Output
{
    public class DoneEventArgs : EventArgs
    {
        public DoneEventArgs()
        {
            _item = null;
        }
        public DoneEventArgs(RequestItem item)
        {
            _item = item;
        }

        RequestItem _item;

        public RequestItem Item
        {
            get
            {
                if (HasError)
                    throw Error;
                else
                    return _item;
            }
            set
            {
                _item = value;
            }
        }
        public bool HasError
        {
            get { return _item.IsError; }
            set { _item.IsError = value; }
        }
        public Exception Error
        {
            get { return _item.Error; }
            set { _item.Error = value; }
        }
    }

    public delegate void OutputEventHandler(object sender,DoneEventArgs e);
}
